package org.example.modelTest;

import org.example.util.DateUtil;

import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;

public class DateTest {
    public static double getMinuteDiff(long startTime, long endTime) {
        LocalDateTime startDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneId.systemDefault());
        LocalDateTime endDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneId.systemDefault());
        Duration duration = Duration.between(startDateTime, endDateTime);
        long seconds = duration.getSeconds();
        double minutes = seconds / 60.0;
        return minutes;
    }
    public static void main(String[] args){
//        String date1="2021-03-01";
//        String date2="2023-04-26";
//        long[] ts1=DateUtil.getDayStartAndEndTimestamp(date1);
//        long[] ts2=DateUtil.getDayStartAndEndTimestamp(date2);
//        System.out.println("Date1: start: "+ DateUtil.timestampToString(ts1[0])+" "+ts1[0]+" end: "+ DateUtil.timestampToString(ts1[1])+" "+ts1[1] + " Previous: "+DateUtil.getPreviousDay(date1) );
//        System.out.println("Date2: start: "+ DateUtil.timestampToString(ts2[0])+" "+ts2[0]+" end: "+ DateUtil.timestampToString(ts2[1])+" "+ts2[1] + " Previous: "+DateUtil.getPreviousDay(date2));
        long ts0=1686639432000L; // 2023-06-13 14:57:12 初始
        long ts0_1=1686643032000L;//2023-06-13 15:57:12 1h
        long ts0_2=1686725831000L;//2023-06-13 15:57:12 差1s正好24h
        long ts1_5=1686733032000L;//2023-06-14 14:57:12 正好24h
        long ts2=1686729432000L; // 2023-06-14 15:57:12 超过24h
        long ts2_5=1686733032000L;//2023-06-14 16:57:12 超过24h
        long ts3=1686812232000L; // 2023-06-15 14:57:12 正好48h
        System.out.println(DateUtil.getDaysBetween(ts0,ts0_2));

    }
}
